$(document).ready(function () {
    fcysxx.onload();
})

var fcysxx = (function () {

    var init = function () {
//		$(window).resize(function(){
//			fcysxx.windowResize()
//		});
    }

    return {
        onload : function () {
            init();
//          fcysxx.windowResize()
            fcysxx.formTab();
            fcysxx.tableDataCj();
            fcysxx.tableDataCz();
            fcysxx.cJbgClick();
            fcysxx.cZbgClick();
        },
         /*页面大小计算*/
        windowResize:function(){
         	var content_xxcj_h=$(document).height()-20;
			$(".wxl_syxxcj_box").css("height",content_xxcj_h+"px");
		},
        /*tab选项卡*/
       formTab:function(){
	       	$(".wxl_fcys_tab span").click(function(){
	       		$(this).addClass("active").siblings("span").removeClass("active");
				var n=$(this).index();
				$(".wxl_cztdysxx_con>.wxl_table_box").eq(n).show().siblings(".wxl_table_box").hide();
				
			})
       },
        /*table表格数据从价*/
	    tableDataCj:function(){
	    	var data = [{
	 				"houseMoney": "455",
	 				"cZhouseMoney": "500",
	 				"cZarea": "60000",
	 				"taxRatio": "1",
	 				"reduceNum": "5666",
	 				"dateStart": "2018-1-23",
	 				"dateEnd": "2018-1-23",
	 				"operation": null
	 			},
	 			{
	 				"houseMoney": "455",
	 				"cZhouseMoney": "500",
	 				"cZarea": "60000",
	 				"taxRatio": "1",
	 				"reduceNum": "5666",
	 				"dateStart": "2018-1-23",
	 				"dateEnd": "2018-1-25",
	 				"operation": null
	 			}
	 		];
	 		$('#wxlFcysxxCj').DataTable({
	 			"data": data,
	 			"columnDefs": [{
	 					"targets": -1,
	 					"data": null,
	 					"render": function(data, type, full, meta) {
	 						return '<span class="btn wxl_bg_yel wxl_btn_bg">变更</span>'
	 					}
	 				},
	 				{
	 					'targets': 0,
	 					'className': 'dt-body-center',
	 					'render': function(data, type, row) {
	 						return '<input class="checkchild" type="checkbox"/>';
	 					}
	 				}
	 			],
	 			"columns": [
	 			    {
	 					"data": "btn"
	 				},
	 			    {
	 					"data": "houseMoney"
	 				},
	 				{
	 					"data": "cZhouseMoney"
	 				},
	 				{
	 					"data": "cZarea"
	 				},
	 				{
	 					"data": "taxRatio"
	 				},
	 				{
	 					"data": "reduceNum"
	 				},
	 				{
	 					"data": "dateStart"
	 				},
	 				{
	 					"data": "dateEnd"
	 				},
	 				{
	 					"data": "operation"
	 				}
	 			],
	// 			"paging": false,
	 			"info": false,
	 			"lengthChange": false,
	 			"searching": false
	 		})
	    },
	    
	     /*table表格数据从租*/
	    tableDataCz:function(){
	    	var data = [{
	 				"htczArea": "455",
	 				"htczMoney": "500",
	 				"htzlDateStart": "2018-12-19",
	 				"htzlDateEnd": "2018-12-30",
	 				"sbzjzlDateStart": "2018-12-19",
	 				"sbzjzlDateEnd": "2018-1-23",
	 				"cZtaxpayerNum": "444",
	 				"cZtaxpayerName": "张三",
	 				"sbzjMoney": "555",
	 				"reduceNum": "9999",
	 				"operation": null
	 			},
	 			{
	 				"htczArea": "456",
	 				"htczMoney": "5060",
	 				"htzlDateStart": "2018-12-19",
	 				"htzlDateEnd": "2018-12-30",
	 				"sbzjzlDateStart": "2018-12-19",
	 				"sbzjzlDateEnd": "2018-1-23",
	 				"cZtaxpayerNum": "7777",
	 				"cZtaxpayerName": "张里",
	 				"sbzjMoney": "555",
	 				"reduceNum": "9999",
	 				"operation": null
	 			}
	 		];
	 		$('#wxlFcysxxCz').DataTable({
	 			"data": data,
	 			"columnDefs": [{
	 					"targets": -1,
	 					"data": null,
	 					"render": function(data, type, full, meta) {
	 						return '<span class="btn wxl_bg_yel wxl_btn_bg">变更</span>'
	 					}
	 				},
	 				{
	 					'targets': 0,
	 					'className': 'dt-body-center',
	 					'render': function(data, type, row) {
	 						return '<input class="checkchild" type="checkbox"/>';
	 					}
	 				}
	 			],
	 			"columns": [
	 			    {
	 					"data": "btn"
	 				},
	 			    {
	 					"data": "htczArea"
	 				},
	 				{
	 					"data": "htczMoney"
	 				},
	 				{
	 					"data": "htzlDateStart"
	 				},
	 				{
	 					"data": "htzlDateEnd"
	 				},
	 				{
	 					"data": "sbzjzlDateStart"
	 				},
	 				{
	 					"data": "sbzjzlDateEnd"
	 				},
	 				{
	 					"data": "cZtaxpayerNum"
	 				},
	 				{
	 					"data": "cZtaxpayerName"
	 				},
	 				{
	 					"data": "sbzjMoney"
	 				},
	 				{
	 					"data": "reduceNum"
	 				},
	 				{
	 					"data": "operation"
	 				}
	 			],
	// 			"paging": false,
	 			"info": false,
	 			"lengthChange": false,
	 			"searching": false
	 		})
	    },
	  
	      /*从价信息弹框*/
	    fwysCj:function(){
	    	var html='<div class="wxl_ysxx_tk wxl_fcysxx_tk_cj">'+
					'	<form action="">'+
					'		<ul>'+
					'			<li><label>房产原值</label><input type="text" /></li>'+
					'			<li><label>其中：出租房产原值</label><input type="text" /></li>'+
					'			<li><label>出租面积</label><input type="text" /></li>'+
					'			<li><label>计税比例</label><input type="text" /></li>'+
					'			<li>'+
					'				<label for="">纳税义务有效期起</label>'+
					'				<input class="layui-input" id="wxl_date1" type="text" placeholder="yyyy-MM-dd">'+
					'				<span class="wxl_date"></span>'+
					'			</li>'+
					'			<li>'+
					'				<label for="">纳税义务有效期止</label>'+
					'				<input class="layui-input" id="wxl_date2" type="text" placeholder="yyyy-MM-dd">'+
					'				<span class="wxl_date"></span>'+
					'			</li>'+
					'		</ul>'+
					'	</form>'+
					'		<div class="wxl_table_box wxl_table_box_pad">'+
					'			<table id="tkConCj" class="display" cellspacing="0" width="100%">'+
					'		        <thead>'+
					'		            <tr>'+
					'			            <th style="width:7%"><input type="checkbox" /></th>'+
					'						<th>减免性质代码</th>'+
					'						<th>减免税房产原值</th>'+
					'						<th>月减免金额</th>'+
					'						<th>有效期起</th>'+
					'						<th>有效期止</th>'+
					'						<th>操作</th>'+
					'		            </tr>'+
					'		        </thead>'+
					'		        <tbody>'+
					'		        </tbody>'+
					'             </table>'+
					'             <p class="wxl_btn_box wxl_bg_fff" style=""><span class="wxl_btn wxl_bg_lan1" onclick="fcysxx.saveForm()">保存</span></p>'+
					'		</div>'+
				    '    </div>';
	     	layui.use('layer', function() {
					var layer = layui.layer;
					layer.open({
						type: 1,
						id:"layer_date1",
						skin: 'layui-layer-demo', //样式类名
						closeBtn: 1, //不显示关闭按钮
						anim: 2,
						title: '房屋应税信息（从价）',
						area: ['98%', '500px'],
						shadeClose: true, //开启遮罩关闭
						content: html
					});
				});
	    },
	      /*从租信息弹框*/
	    fwysCz:function(){
	     	layui.use('layer', function() {
					var layer = layui.layer;
					layer.open({
						type: 1,
						id:"layer_date2",
						skin: 'layui-layer-demo', //样式类名
						closeBtn: 1, //不显示关闭按钮
						anim: 2,
						title: '房屋应税信息（从租）',
						area: ['98%', '500px'],
						shadeClose: true, //开启遮罩关闭
						content: $('.wxl_fcysxx_tk_cz_box').html()
					});
				});
	    },
	     /*从价信息弹框表格数据*/
	    cJTkTableDate:function(){
	    	var data = [
	    		{
	 				"reduceCode": "QQQQ",
	 				"reduceFcMoney": "500",
	 				"yueReduceMoney": "111111",
	 				"DateStart": "2018-12-30",
	 				"DateEnd": "2018-12-19",
	 				"operation": null
	 			},
	 			{
	 				"reduceCode": "AAAAA",
	 				"reduceFcMoney": "500",
	 				"yueReduceMoney": "111111",
	 				"DateStart": "2018-12-30",
	 				"DateEnd": "2018-12-19",
	 				"operation": null
	 			}
	 		];
	 		$('#tkConCj').DataTable({
	 			"data": data,
	 			"columnDefs": [{
	 					"targets": -1,
	 					"data": null,
	 					"render": function(data, type, full, meta) {
	 						return '<span class="btn wxl_bg_lan1 wxl_btn_add">增加</span><span class="btn wxl_bg_red wxl_btn_deleted">删除</span>'
	 					}
	 				},
	 				{
	 					'targets': 0,
	 					'className': 'dt-body-center',
	 					'render': function(data, type, row) {
	 						return '<input class="checkchild" type="checkbox"/>';
	 					}
	 				}
	 			],
	 			"columns": [
	 			    {
	 					"data": "btn"
	 				},
	 			    {
	 					"data": "reduceCode"
	 				},
	 				{
	 					"data": "reduceFcMoney"
	 				},
	 				{
	 					"data": "yueReduceMoney"
	 				},
	 				{
	 					"data": "DateStart"
	 				},
	 				{
	 					"data": "DateEnd"
	 				},
	 				{
	 					"data": "operation"
	 				}
	 			],
	// 			"paging": false,
	 			"info": false,
	 			"lengthChange": false,
	 			"searching": false
	 		})
	    },
	      /*从价信息弹框表格数据*/
	    cZTkTableDate:function(){
	    	var data = [
	    		{
	 				"reduceCode": "BBBBBSS",
	 				"reduceFcMoney": "500",
	 				"yueReduceMoney": "111111",
	 				"DateStart": "2018-12-30",
	 				"DateEnd": "2018-12-19",
	 				"operation": null
	 			},
	 			{
	 				"reduceCode": "AAAAA",
	 				"reduceFcMoney": "500",
	 				"yueReduceMoney": "111111",
	 				"DateStart": "2018-12-30",
	 				"DateEnd": "2018-12-19",
	 				"operation": null
	 			}
	 		];
	 		$('#tkConCz').DataTable({
	 			"data": data,
	 			"columnDefs": [{
	 					"targets": -1,
	 					"data": null,
	 					"render": function(data, type, full, meta) {
	 						return '<span class="btn wxl_bg_lan1 wxl_btn_add">增加</span><span class="btn wxl_bg_red wxl_btn_deleted">删除</span>'
	 					}
	 				},
	 				{
	 					'targets': 0,
	 					'className': 'dt-body-center',
	 					'render': function(data, type, row) {
	 						return '<input class="checkchild" type="checkbox"/>';
	 					}
	 				}
	 			],
	 			"columns": [
	 			    {
	 					"data": "btn"
	 				},
	 			    {
	 					"data": "reduceCode"
	 				},
	 				{
	 					"data": "reduceFcMoney"
	 				},
	 				{
	 					"data": "yueReduceMoney"
	 				},
	 				{
	 					"data": "DateStart"
	 				},
	 				{
	 					"data": "DateEnd"
	 				},
	 				{
	 					"data": "operation"
	 				}
	 			],
	// 			"paging": false,
	 			"info": false,
	 			"lengthChange": false,
	 			"searching": false
	 		})
	    },
	       /*点击从价变更按钮事件*/
	     cJbgClick:function(){
	     	$("#wxlFcysxxCj").on("click",".wxl_btn_bg", function(){
				fcysxx.fwysCj();
				fcysxx.dateShow();
				fcysxx.cJTkTableDate()
			});
	     },
	      /*点击从租变更按钮事件*/
	     cZbgClick:function(){
	     	$("#wxlFcysxxCz").on("click",".wxl_btn_bg", function(){
				fcysxx.fwysCz();
				fcysxx.dateShow();
				fcysxx.cZTkTableDate();
				
			});
	     },
	    /*日期显示*/
	   dateShow:function(){
		   	layui.use('laydate', function(){
			  var laydate = layui.laydate;
			  laydate.render({
				    elem: '#layer_date1 #wxl_date1'
				    ,theme: 'molv'
			 });
			  laydate.render({
			    elem: '#layer_date1 #wxl_date2'
			    ,theme: 'molv'
			  });
			   laydate.render({
			    elem: '#layer_date2 #wxl_date3'
			    ,theme: 'molv'
			  });
			   laydate.render({
			    elem: '#layer_date2 #wxl_date4'
			    ,theme: 'molv'
			  });
	
			})
	   },
	    /*保存关闭弹框*/
	     saveForm:function(){
	     	layer.closeAll()
	     }
    }
})();
